package com.weilive.core.netty.server;

import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.handler.codec.http.HttpChunkAggregator;
import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
import org.jboss.netty.handler.stream.ChunkedWriteHandler;

import com.weilive.core.netty.NettyServer;
import com.weilive.core.netty.handler.NettyMultiWebRequestHandler;

public class NettyMultiWebServer extends NettyServer
{
    
    @Override
    protected ChannelPipeline createPipeline() throws Exception
    {
        ChannelPipeline pipeline = Channels.pipeline();
        pipeline.addLast("decoder", new HttpRequestDecoder());
        pipeline.addLast("aggregator", new HttpChunkAggregator(655360));
        pipeline.addLast("encoder", new HttpResponseEncoder());
        //pipeline.addLast("deflater", new HttpContentCompressor());
        pipeline.addLast("chunkwrite", new ChunkedWriteHandler());
        pipeline.addLast("handler", new NettyMultiWebRequestHandler());
        return pipeline;
    }
}
